// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

#ifndef RECOVERY_IMAGE_OBSERVER_H_
#define RECOVERY_IMAGE_OBSERVER_H_

#include "recovery_image.h"
#include "status/rot_status.h"


/**
 * Interface for notifying observers of recovery image events.  Unwanted event notifications will be
 * set to null.
 */
struct recovery_image_observer {
	/**
	 * Notification that a new recovery image has been made the active recovery image.
	 *
	 * Arguments sent with this notification will not be null.
	 *
	 * @param observer The observer being notified.
	 * @param active The recovery image that was activated.
	 */
	void (*on_recovery_image_activated) (struct recovery_image_observer *observer,
		struct recovery_image *active);

	/**
	 * Notification that there is no longer an active recovery image.
	 *
	 * Arguments sent with this notification will not be null.
	 *
	 * @param observer The observer being notified.
	 */
	void (*on_recovery_image_deactivated) (struct recovery_image_observer *observer);
};


#define	RECOVERY_IMAGE_OBSERVER_ERROR(code)		ROT_ERROR (ROT_MODULE_RECOVERY_IMAGE_OBSERVER, code)

/**
 * Error codes that can be generated by a recovery image observer.
 */
enum {
	RECOVERY_IMAGE_OBSERVER_INVALID_ARGUMENT = RECOVERY_IMAGE_OBSERVER_ERROR (0x00),	/**< Input parameter is null or not valid. */
	RECOVERY_IMAGE_OBSERVER_NO_MEMORY = RECOVERY_IMAGE_OBSERVER_ERROR (0x01),			/**< Memory allocation failed. */
};


#endif /* RECOVERY_IMAGE_OBSERVER_H_ */
